import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Util/PageUtil.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyDialog.dart';
import 'package:imember/Widget/MyInput.dart';
import 'package:imember/Widget/MyPage.dart';

import 'CashExpend.dart';

class SummaryCount extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SummaryCountState();
  }
}

class SummaryCountState extends State {
  nextStep() {
    showTextDialog(context, "面額數量與卡金額不可皆空白");
    PageUtil().open(context, CashExpend());
  }

  @override
  Widget build(BuildContext context) {
    return MyPage(
        Container(
          margin: EdgeInsets.only(top: 12),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Row(mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [
                Column(children: [
                  Input("\$2000", controller: TextEditingController()),
                  Input("\$1000"),
                  Input("\$500"),
                  Input("\$200"),
                  Input("\$100"),
                ]),
                Column(children: [
                  Input("\$50"),
                  Input("\$10"),
                  Input("\$5"),
                  Input("\$1"),
                ])
              ]),
              Container(height: 25),
              Expanded(
                child: Column(children: [
                  Input("信用卡金額", isLong: true),
                  Input("人民幣金額", isLong: true),
                  Input("禮券金額", isLong: true),
                ]),
              ),
              OrangeBtn("下一步", width: 94, height: 32, margin: EdgeInsets.fromLTRB(0, 0, 74, 30), onTap: nextStep)
            ],
          ),
        ),
        title: "清點");
  }
}

class Input extends StatelessWidget {
  bool? isLong;
  String title;
  TextEditingController? controller;

  Input(this.title, {this.isLong, this.controller});

  @override
  Widget build(BuildContext context) {
    isLong = isLong ?? false;
    return Container(
        margin: EdgeInsets.only(top: 20),
        alignment: Alignment.center,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(width: isLong! ? 100 : 70, child: Text(title, style: TextStyle(fontSize: 17, color: MyColor.C70))),
            Container(
                height: 36,
                width: isLong! ? 390 : 330,
                padding: EdgeInsets.fromLTRB(18, 0, 18, 0),
                decoration: Global.getBoxBg(18, MyColor.E7),
                child: NormalInput(inputType: NormalInput.Number, fontSize: 18, controller: controller))
          ],
        ));
  }
}
